package com.yb.oldlearning;

/**
 * 定义任务：实现Runnable接口，编写run()方法
 * @author yanbiao
 */
public class LiftOff implements Runnable{
	protected int countDown = 10;
	private static int taskCount = 0;
	private final int id = taskCount++;//标识任务的实例
	public LiftOff(){}
	public LiftOff(int countDown){
		this.countDown = countDown;
	}
	public String status(){
		return "#" + id +"(" + (countDown>0?countDown: "LiftOff!") + ")";
	}
	public void run(){
		while (countDown-- > 0) {
			System.out.println(status());
			Thread.yield();//线程调度器
		}
	}
}
